<?php
namespace app\techn_api_n\controller\v1;
use think\Db;
use think\Request;


class Talk extends Base
{
	public function _initialize()
	{
        parent::_initialize();
        $this->IsLogin(); //验证登录
        $this->IsTechn(); //验证技师


    }


    public function talk_list(Request $request){
        $param = $request->param();
        $user = $this->user;
        $techn_id = Db::name('techn')->where('user_id',$user['id'])->value('id');

        $list = Db::name('talk')->where('techn_id',$techn_id)->where('delete_time',0)->order('id desc')->select();
//        $list = Db::name('talk')->where('delete_time',0)->group('techn_id')->column('count(id)','techn_id');
//        dump($list);die;
        foreach ($list as  $key => $value){
            $list[$key]['add_time_time'] = date('Y-m-d H:i',$value['add_time']);
        }
        $return['code'] = 0;
        $return['msg'] = '获取成功';
        $return['data'] = $list;
        echo json_encode($return);
    }

    public function order_baobei(Request $request){
            $param = $request->param();
            if (!empty($param['content'] && !empty($param['order_id']))){
                $re = Db::name('order_detail')->where('order_id',$param['order_id'])->update(['baobei'=>$param['content'],'upd_time'=>time()]);
                if ($re){
                    $return['code'] = 0;
                    $return['msg'] = '报备成功';
                }else{
                    $return['code'] = -1;
                    $return['msg'] = '报备失败,请重试';
                }
            }
        echo json_encode($return);
        }

}